package com.eastfair.projectcore.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.eastfair.core.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.projectcore.enumeration.MenuMenuTypeEnum;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 菜单
 * </p>
 *
 * @author ligang
 * @since 2021-10-28
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("c_menu")
@ApiModel(value = "Menu", description = "菜单")
@AllArgsConstructor
public class Menu extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 菜单名称
     */
    @ApiModelProperty(value = "菜单名称")
    @Size(max = 255, message = "菜单名称长度不能超过255")
    @TableField(value = "name", condition = LIKE)
    @Excel(name = "菜单名称")
    private String name;

    /**
     * 菜单名称（英文）
     */
    @ApiModelProperty(value = "菜单名称（英文）")
    @Size(max = 255, message = "菜单名称（英文）长度不能超过255")
    @TableField(value = "en_name", condition = LIKE)
    @Excel(name = "菜单名称（英文）")
    private String enName;

    /**
     * code码
     */
    @ApiModelProperty(value = "code码")
    @NotEmpty(message = "请填写code码")
    @Size(max = 255, message = "code码长度不能超过255")
    @TableField(value = "code", condition = LIKE)
    @Excel(name = "code码")
    private String code;

    /**
     * 菜单类型 #{catalog:目录;menu:菜单;button:按钮}
     */
    @ApiModelProperty(value = "菜单类型 #{catalog:目录;menu:菜单;button:按钮}")
    @TableField(value = "menu_type")
    @Excel(name = "菜单类型 #{catalog:目录;menu:菜单;button:按钮}", replace = {"目录_CATALOG", "菜单_MENU", "按钮_BUTTON",  "_null"})
    private MenuMenuTypeEnum menuType;

    /**
     * 值例如：www.baidu  / 内联地址，内链则是前端用的路由地址
     */
    @ApiModelProperty(value = "值例如：www.baidu  / 内联地址，内链则是前端用的路由地址")
    @Size(max = 255, message = "值例如：www.baidu  / 内联地址，内链则是前端用的路由地址长度不能超过255")
    @TableField(value = "link", condition = LIKE)
    @Excel(name = "值例如：www.baidu  / 内联地址，内链则是前端用的路由地址")
    private String link;

    /**
     * 路由参数
     */
    @ApiModelProperty(value = "路由参数")
    @Size(max = 255, message = "路由参数长度不能超过255")
    @TableField(value = "link_param", condition = LIKE)
    @Excel(name = "路由参数")
    private String linkParam;

    /**
     * 组件路径,前端资源路径，给前端用的
     */
    @ApiModelProperty(value = "组件路径,前端资源路径，给前端用的")
    @Size(max = 255, message = "组件路径,前端资源路径，给前端用的长度不能超过255")
    @TableField(value = "module_url", condition = LIKE)
    @Excel(name = "组件路径,前端资源路径，给前端用的")
    private String moduleUrl;

    /**
     * 权限字符
     */
    @ApiModelProperty(value = "权限字符")
    @Size(max = 255, message = "权限字符长度不能超过255")
    @TableField(value = "permission", condition = LIKE)
    @Excel(name = "权限字符")
    private String permission;

    /**
     * icon
     */
    @ApiModelProperty(value = "icon")
    @Size(max = 255, message = "icon长度不能超过255")
    @TableField(value = "icon", condition = LIKE)
    @Excel(name = "icon")
    private String icon;

    /**
     * 排序
     */
    @ApiModelProperty(value = "排序")
    @TableField(value = "sequence")
    @Excel(name = "排序")
    private Integer sequence;

    /**
     * 父级id
     */
    @ApiModelProperty(value = "父级id")
    @NotNull(message = "请填写父级id")
    @TableField(value = "parent_id")
    @Excel(name = "父级id")
    private Long parentId;

    /**
     * 是否外链(默认1：是 0:否)
     */
    @ApiModelProperty(value = "是否外链(默认1：是 0:否)")
    @TableField(value = "is_out_link")
    @Excel(name = "是否外链(默认1：是 0:否)")
    private Integer isOutLink;

    /**
     * 是否显示(默认1：是 0:否)
     */
    @ApiModelProperty(value = "是否显示(默认1：是 0:否)")
    @TableField(value = "is_show")
    @Excel(name = "是否显示(默认1：是 0:否)")
    private Integer isShow;

    /**
     * 是否生效(默认1：可用 0:不可用)
     */
    @ApiModelProperty(value = "是否生效(默认1：可用 0:不可用)")
    @TableField(value = "is_enabled")
    @Excel(name = "是否生效(默认1：可用 0:不可用)")
    private Integer isEnabled;

    /**
     * 是否删除(默认0：未删除 1:已删除)
     */
    @ApiModelProperty(value = "是否删除(默认0：未删除 1:已删除)")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除(默认0：未删除 1:已删除)")
    private Integer isDeleted;


    @Builder
    public Menu(Long id, LocalDateTime createTime, Long createdBy, LocalDateTime updateTime, Long updatedBy, 
                    String name, String enName, String code, MenuMenuTypeEnum menuType, String link, 
                    String linkParam, String moduleUrl, String permission, String icon, Integer sequence, Long parentId, 
                    Integer isOutLink, Integer isShow, Integer isEnabled, Integer isDeleted) {
        this.id = id;
        this.createTime = createTime;
        this.createdBy = createdBy;
        this.updateTime = updateTime;
        this.updatedBy = updatedBy;
        this.name = name;
        this.enName = enName;
        this.code = code;
        this.menuType = menuType;
        this.link = link;
        this.linkParam = linkParam;
        this.moduleUrl = moduleUrl;
        this.permission = permission;
        this.icon = icon;
        this.sequence = sequence;
        this.parentId = parentId;
        this.isOutLink = isOutLink;
        this.isShow = isShow;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
    }

}
